package com.wzdigit.wms.basic.mapper.core.transfer;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.wzdigit.framework.orm.mybatis.MyBatisRepository;
import com.wzdigit.wms.basic.client.request.outstock.PickMaterialRequest;
import com.wzdigit.wms.basic.client.request.transfer.GdnCtnrRequest;
import com.wzdigit.wms.basic.client.request.transfer.SearchGdnHeaderReportRequest;
import com.wzdigit.wms.basic.client.request.transfer.SearchGdnHeaderRequest;
import com.wzdigit.wms.basic.client.response.outstock.PickNoticeHeaderResponse;
import com.wzdigit.wms.basic.client.response.transfer.CtnrLoadingPrintResponse;
import com.wzdigit.wms.basic.client.response.transfer.GdnCtnrTaskResponse;
import com.wzdigit.wms.basic.client.response.transfer.GdnHeaderListResponse;
import com.wzdigit.wms.basic.client.response.transfer.GdnHeaderReportResponse;
import com.wzdigit.wms.basic.domain.dtos.transfer.GdnOmsInfoDto;
import com.wzdigit.wms.basic.domain.transfer.GdnHeader;
import org.apache.ibatis.annotations.Param;

import java.math.BigDecimal;
import java.util.Date;
import java.util.List;
import java.util.Map;

/**
 * <p>
 * 发货单,GDN=Goods Delivery Notes Mapper 接口
 * </p>
 *
 * @author 
 * @since 2021-02-22
 */
@MyBatisRepository
public interface GdnHeaderMapper extends BaseMapper<GdnHeader> {
	
	int updatePrint(@Param("gdnPrint") Integer gdnPrint,
			@Param("remainDocPrint") Integer remainDocPrint, @Param("modifyUser") String modifyUser,
			@Param("gdnHeaderIdList") List<Long> gdnHeaderIdList);
	
	int updateCommentsAndErrorCommentsByGdnHeaderId(@Param("comments")String comments, @Param("errorComments")String errorComments,
							 @Param("modifyUser")String modifyUser, @Param("gdnHeaderId")Integer gdnHeaderId);

	List<GdnHeaderListResponse> selectAll(
			@Param("dto")SearchGdnHeaderRequest dto, 
			@Param("gdnDtlStatusList")List<Integer> gdnDtlStatusList, 
			@Param("beginShipDate")Date beginShipDate, @Param("endShipDate")Date endShipDate,
			@Param("beginClosingDate")Date beginClosingDate, @Param("endClosingDate")Date endClosingDate);

	List<GdnCtnrTaskResponse> selectGndCtnrList(GdnCtnrRequest gdnCtnrRequest);
	
	List<GdnHeaderReportResponse> selectGdnHeaderReportList(
			@Param("dto")SearchGdnHeaderReportRequest dto,
			@Param("gdnTypeList") List<String> gdnTypeList,
			@Param("beginDate") Date beginDate,
			@Param("endDate") Date endDate,
			@Param("beginCloseDate") Date beginCloseDate,
			@Param("endCloseDate") Date endCloseDate,
			@Param("gdnDtlStatus") Integer gdnDtlStatus);
	
	int updateStatusById(@Param("status") Integer status, 
			@Param("modifyUser") String modifyUser, @Param("gdnHeaderId") Long gdnHeaderId);

	int updateStatusBySourceShipNoticeAndGdnType(@Param("status") Integer status, 
			@Param("sourceShipNotice") String sourceShipNotice, @Param("gdnType") String gdnType);
	
    void updateStatusByNo(@Param("status") int status, @Param("o") String o);

	List<GdnOmsInfoDto> selectOmsInfo(String gdnNo);

	List<GdnCtnrTaskResponse> selectGndCtnrListAllStatus(GdnCtnrRequest gdnCtnrRequest);
	
	/*发货单打印*/
	CtnrLoadingPrintResponse selectPrintByGdnHeaderId(Integer gdnHeaderId);
	
	// 分组：装柜发货单号、发货通知单号、品牌、实际柜号、封条号、出口国、出货港、业务员、订舱号、备注
	List<Map<String, Object>> selectPrintAllGroupBy(String gdnNo);

	BigDecimal selectOrderQtySumByGdnNo(String gdnNo);
	
	// 更新排柜信息
	// 柜号(实际)、订舱号、封条号、车牌号
	int updateCtnrLoading(GdnHeader gdnHeader);

	List<GdnHeader> getAll();

	List<PickNoticeHeaderResponse> selectOwnOrder(@Param("whsIdList") List<Integer> whsIdList,
												  @Param("skuIdList") List<Integer> skuIdList,
												  @Param("pickMaterialRequest") PickMaterialRequest pickMaterialRequest,
												  @Param("headerNotAllowList") List<Integer> headerNotAllowList,
												  @Param("dtlMustStatusList") List<Integer> dtlMustStatusList,
												  @Param("allowTypeList") List<String> allowTypeList);


	/*原材料 送货单(出库单)列表查询
	    * @param dto
		* @param gdnDtlStatusList 单据状态列表
		* @param shipDateStart
		* @param shipDateEnd
		* @param approvedDateStart
		* @param approvedDateEnd
	    * @return java.util.List<com.wzdigit.wms.basic.client.response.transfer.GdnHeaderListResponse>
	    * @author shuaic
	    * @date 2021/7/14 10:18
	*/
	List<GdnHeaderListResponse> selectAllRaw(
			@Param("dto")SearchGdnHeaderRequest dto,
			@Param("gdnDtlStatusList")List<Integer> gdnDtlStatusList,
			@Param("shipDateStart")Date shipDateStart, @Param("shipDateEnd")Date shipDateEnd,
			@Param("approvedDateStart")Date approvedDateStart, @Param("approvedDateEnd")Date approvedDateEnd,
			@Param("gdnTypeList")List<String> gdnTypeList);

	int updateTmsFalg(@Param("gdnHeaderId") BigDecimal gdnHeaderId);

	//更新首次分库时间
	int updateGdnSpliDate(@Param("gdnNo") String gdnNo);

	//清空首次分库时间
	int updateGdnSpliNull(@Param("gdnNo") String gdnNo);
    //更新表头为需要做交接确认
    int updateNeedSure(@Param("headerId") Long gdnHeaderId,@Param("code") int code);
}
